package cn.wolfcode.web.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;

import cn.wolfcode.common.exception.BusinessException;
import cn.wolfcode.common.web.CommonCodeMsg;
import cn.wolfcode.common.web.Result;
import cn.wolfcode.domain.OperateIntergralVo;
import cn.wolfcode.service.IUsableIntegralService;
import cn.wolfcode.web.msg.IntergralCodeMsg;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;


@RestController
@RequestMapping("/intergral")
public class IntegralController {
  
    @Autowired
    private IUsableIntegralService usableIntegralService;
    
    @RequestMapping("/payOnIntergral")
    Result<Boolean> payOnIntergral(@RequestBody  OperateIntergralVo intergralVo){
        if (StringUtils.isEmpty(intergralVo)){
            throw new BusinessException(CommonCodeMsg.NO_PARAM_ERROR);
        }
    
        return Result.success(usableIntegralService.payOnIntergral(intergralVo));
    }
    
    
    @RequestMapping("/refundOnintergral")
    Result<Boolean> refundOnintergral(@RequestBody OperateIntergralVo intergralVo,BusinessActionContext context){
        if (StringUtils.isEmpty(intergralVo)){
            throw new BusinessException(CommonCodeMsg.NO_PARAM_ERROR);
        }
    
    
        return Result.success(usableIntegralService.refundTry(null,intergralVo));
    }
    
}
